#ifndef WEBSOCKET_SERVER_H
#define WEBSOCKET_SERVER_H

#include <libwebsockets.h>

#include <map>
#include <string>
#include <thread>
#include <mutex>

class WebSocketServer {
public:
    WebSocketServer(int port);
    ~WebSocketServer();

    void start();
    void stop();

private:

    static int callback_websockets(struct lws *wsi,
                                   enum lws_callback_reasons reason,
                                   void *user, void *in, size_t len);
    void run();

    struct lws_context *context;
    int port;
    std::thread server_thread;
    std::mutex context_mutex;
    bool running;

};

#endif // WEBSOCKET_SERVER_H
